
cc.Class({
    extends: cc.Component,

    properties: {
        className:"roomrulelayer",

    },

    // LIFE-CYCLE CALLBACKS:

    onLoad: function () {
        this.node.thisJS = this; 
        this.content = cc.find("content",this.node);
        this.citem = cc.find("citem",this.node);
        this.loadrule = false ;
    },

    updateView:function(info){    
        dump(info)
        if(this.loadrule){
            return ;
        }
        var resultInfo = [] ;

        var tempInfo = {};
        tempInfo.title = "底分";
        tempInfo.content = info["gold_base_chip"] +"分";
        resultInfo.push(tempInfo);

        var tempInfo = {};
        tempInfo.title = "叫分列表";
        tempInfo.content  = "";
        for(var i=0;i<info["gold_score_list"].length;i++){
            tempInfo.content = tempInfo.content + info["gold_score_list"][i];
            if(i<info["gold_score_list"].length-1){
                tempInfo.content = tempInfo.content + "," 
            }
        }
        GameData.gold_score_list = info["gold_score_list"] ;
        
        resultInfo.push(tempInfo);

        var tempInfo = {};
        tempInfo.title = "看牌限制";
        if(info["look_card_limit"]==0){
            tempInfo.content = "无"
        }else{
            tempInfo.content = info["look_card_limit"] +"分";
        }
        resultInfo.push(tempInfo);


        var tempInfo = {};
        tempInfo.title = "比牌限制";
        if(info["compare_limit"]==0){
            tempInfo.content = "无"
        }else{
            tempInfo.content = info["compare_limit"] +"分";
        }
        resultInfo.push(tempInfo);

        var tempInfo = {};
        tempInfo.title = "局数";
      //  var tempArr = ["","10","20"];
        tempInfo.content = info["gold_play_count"]+"局";
        resultInfo.push(tempInfo);


        var tempInfo = {};
        tempInfo.title = "比分上限";
        if(info["score_limit"]==0){
            tempInfo.content = "无"
        }else{
            tempInfo.content = info["score_limit"] +"分";
        }
        resultInfo.push(tempInfo);

        for(i=0;i<resultInfo.length;i++){
            var tempItem = cc.instantiate(this.citem);
            var title = cc.find("title",tempItem);
            var content = cc.find("content",tempItem);
            this.content.addChild(tempItem);
            title.getComponent(cc.Label).string = resultInfo[i].title;
            content.getComponent(cc.Label).string = resultInfo[i].content;
        }     
        this.loadrule = true ;
    },
    exit:function(){
        this.node.active = false ;
    }
});